package com.fieldchain.ex.fa100.utils.screen;

import android.content.Context;
import android.widget.Toast;

import com.fieldchain.ex.fa100.access.MyApplication;

/**
 * Created by byl on 2018/4/10.
 */

public class MyToast {
    private static Toast TOAST;
    private static final String TAG = "ToastUtil";


    //短时间吐司
    public static void show( int resourceID) {
        show( resourceID, Toast.LENGTH_SHORT);
    }

    //短时间吐司
    public static void show( String text) {
        show(text, Toast.LENGTH_SHORT);
    }

    //短时间吐司
    public static void show(Context context,String text) {
        show(text, Toast.LENGTH_SHORT);
    }

    //自定义时长吐司
    public static void show( Integer resourceID, int duration) {
        String text = MyApplication.getAppContext().getResources().getString(resourceID);// 用于显示的文字
        show( text, duration);
    }

    //自定义时长吐司
    public static void show( final String text, final int duration) {

        if (TOAST == null) {
            TOAST = Toast.makeText(MyApplication.getAppContext(), text, duration);
        } else {
            TOAST.setText(text);
            TOAST.setDuration(duration);
        }

        TOAST.show();
    }
}
